package aaa.com.pp.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.IOException;
import java.nio.charset.Charset;

import aaa.com.pp.R;
import okhttp3.ResponseBody;
import okio.Buffer;
import okio.BufferedSource;
import rx.Subscriber;

public class DemoActivity extends AppCompatActivity {
    Subscriber subscriber;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo);

        subscriber = new Subscriber<ResponseBody>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(ResponseBody responseBody) {
                if (responseBody.contentType() != null) {
                    BufferedSource source = responseBody.source();
                    try {
                        source.request(Long.MAX_VALUE);

                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    Buffer buffer = source.buffer();
                    String jsonString = buffer.readString(Charset.defaultCharset());
                    GsonBuilder builder = new GsonBuilder();
                    Gson gson = new Gson();

                }


            }


        };
    }
}
